//
//  GraphicVC.m
//  Demo
//
//  Created by LG on 2018/12/5.
//  Copyright © 2018 LG. All rights reserved.
//

#import "GraphicVC.h"
#import "GrapicView.h"

@interface GraphicVC ()

@property (nonatomic,strong)CAShapeLayer  *demoView;

@end

@implementation GraphicVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    CAShapeLayer *layer = [[CAShapeLayer alloc]init];
    UIBezierPath *beizePath = [UIBezierPath bezierPath];
    [beizePath moveToPoint:CGPointZero];
    [beizePath addLineToPoint:CGPointMake([UIScreen mainScreen].bounds.size.width, 0)];
    layer.path = beizePath.CGPath;
    layer.strokeColor = [[UIColor redColor]CGColor];
    layer.fillColor = [[UIColor clearColor]CGColor];
    layer.backgroundColor = [[UIColor lightGrayColor]CGColor];
    layer.lineWidth = 10;
    layer.frame = CGRectMake(0, 100, [UIScreen mainScreen].bounds.size.width, 10);
    [self.view.layer addSublayer:layer];
    layer.strokeEnd = .0;
    
    self.demoView = layer;
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd];
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    btn.frame = CGRectMake(100, 200, 100, 100);
    btn.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:btn];
    
    UIButton *btns = [UIButton buttonWithType:UIButtonTypeContactAdd];
    [btns addTarget:self action:@selector(btnClickPlus:) forControlEvents:UIControlEventTouchUpInside];
    btns.frame = CGRectMake(100, 400, 100, 100);
    btns.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:btns];
    
//    GrapicView *gView = [[GrapicView alloc]initWithFrame:CGRectMake(100, 100, 200, 100)];
//    gView.backgroundColor = [UIColor whiteColor];
//    [self.view addSubview:gView];
}

- (void)btnClickPlus:(UIButton*)sender
{
    self.demoView.strokeEnd = self.demoView.strokeEnd+.1;
}

- (void)btnClick:(UIButton*)sender
{
    self.demoView.strokeEnd = self.demoView.strokeEnd-.1;;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
